package com.bz.xtcx.manager.mapper;

import com.bz.xtcx.manager.entity.CmsFloatBox;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.StatementType;

import java.util.List;

/**
 * @author ygl
 * @create 2018-11-08
 * @DESCRIPTION
 **/
public interface CmsFloatBoxMapper {

    @Insert("<script>insert into `cms_float_box`(id, content, img_url, link_url,creater,create_time,updater,update_time)" +
            "   VALUES(#{id},#{content},#{imgUrl},#{linkUrl},#{creater},#{createTime},#{updater},#{updateTime})</script>")
    void insert(CmsFloatBox obj);

    @Delete("delete from `cms_float_box` where id = #{id}")
    void delete(String id);

    @Update("<script>update `cms_float_box` set updater=#{updater}, update_time=#{updateTime}" +
            "<when test='content!=null'> , content=#{content}  </when>" +
            "<when test='imgUrl!=null'> , img_url=#{imgUrl}  </when>" +
            "<when test='linkUrl!=null'> , link_url=#{linkUrl}  </when>" +
            " where id=#{id}" +
            "</script>")
    void update(CmsFloatBox obj);


    @Select("select * from `cms_float_box` where id = #{id}")
    CmsFloatBox selectById(String id);

    @Select("select * from `cms_float_box` ")
    List<CmsFloatBox> findAll();

    @Select("<script>select * from `cms_float_box`  "+
            "<when test='content!=null and content!=\"\"'> where content like CONCAT('%',#{content},'%') </when>" +
            "</script>")
    List<CmsFloatBox> findByContent(@Param("content") String content);
}
